﻿#include "DesktopAssist.h"

#include <QApplication>
#include <QFile>
#include <QSharedMemory>
#include <QStyleFactory>
#include <QSystemSemaphore>
#include <QDebug>


#define HighDpi 1

int main(int argc, char *argv[])
{
    DAFunTools::GetInst()->isRestart = false;
    QApplication::setStyle(QStyleFactory::create("Fusion"));
#if HighDpi
        qputenv("QT_SCALE_FACTOR", "1");
    #if (QT_VERSION >= QT_VERSION_CHECK(6,0,0))
        QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Unset);
    #elif (QT_VERSION >= QT_VERSION_CHECK(5,14,0))
        QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
        QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
        QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::Unset);
    #else
// 。。。。。。 不如不用
       // QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
       // QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
    #endif
#endif
    do{
        QApplication a(argc, argv);
        QApplication::setQuitOnLastWindowClosed(false);
        QFile file(":/Style/qss/Style.qss");
        if( file.open(QFile::ReadOnly))
        {
            QString styleSheet(file.readAll());
            qApp->setStyleSheet(styleSheet);
            file.close();
        }
        DA w;
        //    DASetting setilog;
        w.show();
        //    setilog.show();
        a.exec();
        sleep(1);
    }while(DAFunTools::GetInst()->isRestart);
    return 0;
}
